﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Semantics;
using Semantics.Base;
using System.Runtime.InteropServices;
using System.Data.SqlClient;

namespace Semantics.Example.ParserExample
{
    public partial class SentenceForm : Form
    {
        DataSet ds;
        public SentenceForm()
        {
            InitializeComponent();
            getNewData();

            //DataGridViewButtonColumn作成
            DataGridViewButtonColumn column = new DataGridViewButtonColumn();
            //设定列的名字
            column.Name = "Button";
            //在所有按钮上表示"点击阅览"
            column.UseColumnTextForButtonValue = true;
            column.Text = "Parase";
            //向DataGridView追加
            dataGridView1.Columns.Add(column);
        }

      

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dgv = (DataGridView)sender;
            //如果是"Button"列，按钮被点击
            if (dgv.Columns[e.ColumnIndex].Name == "Button")
            {
                
                //MessageBox.Show(e.RowIndex.ToString() +
                //    "行的按钮被点击了。");
                string Sentence = this.dataGridView1.CurrentRow.Cells["Sentence"].Value.ToString().Trim();
                ParserForm parse = new ParserForm(Sentence,0);
                parse.Show();
            }
        }

        private void getNew_Click(object sender, EventArgs e)
        {
            getNewData();
        }
        public void getNewData()
        {
            ds = new DataSet();
            string tableName = "Sentence";
            dbSql sql = new dbSql();
            ds = sql.GetAll(tableName);
            this.dataGridView1.DataSource = ds.Tables[0];

        }
    }
}
